<script type="text/javascript" charset="utf-8">
	lingcod.onShow(function(){
		$("td.hab_name").hoverIntent(
              function(e){
                  var cell_id = $(this).attr('id');
                  var div_id = "#" + cell_id + "_descript";
                  var offset = $(this).offset();
                  var height = e.layerY + 15;
                  $(div_id).css("position", "absolute").css("left", offset.left).css("top", height).show();
              },
              function() {
                  var cell_id = $(this).attr('id');
                  var div_id = "#" + cell_id + "_descript";
                  $(this).removeClass("selected");
                  $(div_id).hide();
              }
          );
		$("a.explain").hoverIntent(
			function(e){
				var exp_id = $(this).attr('id');
				var exp_div_id = "#" + exp_id + "_text";
                var offset = $(this).offset();
                var height = e.layerY + 15;
				$(exp_div_id).css("position", "absolute").css("left", offset.left - 200).css("top", height).show();
			},
			function(){
				var exp_id = $(this).attr('id');
				var exp_div_id = "#" + exp_id + "_text";
				$(exp_div_id).hide();
			}
		);
	});
</script>
{% if results|length == 0 %}
	<p><em>generated {{ array.date_modified|date:"M d, Y" }}</em></p>
	<p>This array is either empty or has no Marine Protected Area clusters that count towards replication.</p>
{% else %}
	{% regroup results by lop as results_by_lop  %}

		<div id="tabs" class="my_tabs tabs">
			<ul>
			{% for lop in results_by_lop %}
				<li><a href="#{{lop.grouper|cut:" "}}"><span>{{lop.grouper|default:"Ignore LOP"|title}}</span></a></li>
			{% endfor %}
			</ul>
			<p><em>generated {{ array.date_modified|date:"M d, Y" }}</em></p>

			{% for lop in results_by_lop %}
				<div id="{{lop.grouper|cut:" "}}" class="lop">
			    	{% include "array_replication_single_lop.html" %}
				</div>
			{% endfor %}
		</div>

	{% for lop in results_by_lop %}
		{% if forloop.first %}
			{% for cluster in lop.list  %}
				{% if forloop.first %}
					{% for habinfo in cluster.clusterhabitatinfo_set.all %}
						<div class="hab_description" id="hab{{habinfo.habitat.pk}}_descript" style="display:none;">{{habinfo.habitat.description}}</div>
					{% endfor %}
				{% endif %}
			{% endfor %}
		{% endif %}
	{% endfor %}
{% endif %}